﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    public class TeacherEntityConfig : IEntityTypeConfiguration<Teacher>
    {
        public void Configure(EntityTypeBuilder<Teacher> builder)
        {
            builder.ToTable("T_Teachers");
            builder.HasMany(t => t.Students).WithMany(s => s.Teachers)
                //.UsingEntity(j => j.ToTable("T_Teachers_Students"))
                //.UsingEntity<Dictionary<string, object>>( // 自定义中间表
                //    "T_Teachers_Students", // 表名
                //    j => j.HasOne<Student>().WithMany().HasForeignKey("StudentId"), // 外键
                //    j => j.HasOne<Teacher>().WithMany().HasForeignKey("TeacherId")) // 外键
            ;

            //builder.Property(c => c.Message).IsRequired().IsUnicode();
        }
    }
}
